<?php
class Advertiser extends AppModel
{
    var $name = 'Advertiser';
    var $displayField = 'name';
    
    var $hasMany = array(
		'CitiesAdvertiser' => array(
            'className' => 'CitiesAdvertiser',
            'foreignKey' => 'advertiser_id',
            'dependent' => true,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ) ,
        'Attachment' => array(
            'className' => 'Attachment',
            'foreignKey' => 'foreign_id',
            'conditions' => array(
                'Attachment.class =' => 'Advertiser'
            ) ,
            'dependent' => true
        ) ,
    );
    var $hasAndBelongsToMany = array(
		'City' => array(
			'className' => 'City',
			'joinTable' => 'cities_advertisers',
			'foreignKey' => 'advertiser_id',
			'associationForeignKey' => 'city_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);
    function __construct($id = false, $table = null, $ds = null)
    {
        parent::__construct($id, $table, $ds);
        $this->validate = array(
             'name' => array(
                'rule' => 'notempty',
                'allowEmpty' => false,
                'message' => __l('Required')
            ) 
        );
    }
    
    function positions($select=null)
    {
        $positions = array(1=>'center',2=>'sidebar');
        if(!empty($select))
        {
            return $positions[$select];
        }
        return $positions;
    }
}
?>